<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        ul {
            list-style-type: none;
        }
    </style>
	<script src="jquery-3.3.1.min.js"></script>
    <script>
        $(function(){
            $("ul>li").mouseenter(function(){ 
                $(this).css("backgroundColor","red").siblings("li").css("backgroundColor","");
            }).mouseleave(function(){
                $(this).parent().children("li").css("backgroundColor","");
            }).click(function(){
                $(this).prevAll().css("backgroundColor","yellow").end().nextAll().css("backgroundColor","green");
            });
        });
    </script>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
        <li>7</li>
        <li>8</li>
        <li>9</li>
    </ul>
</body>
</html>